/*
 * 注掉的这段是将数据库配置信息独立到db.properties之前的写法
var ioc = {
		dataSource : {
			type : "com.alibaba.druid.pool.DruidDataSource",
			events : {
				create : "init",
				depose : "close"
			},
			fields : {
				url : "jdbc:mysql://127.0.0.1:3306/nutzbook",
				username : "root",
				password : "1",
				maxActive : 100,
				validationQuery : "select 1",
				testWhileIdle : true
			}
		},
		dao : {
			type : "org.nutz.dao.impl.NutDao",
			args : [{refer : "dataSource"}]
		}
};
*/

/**
 * 新写法：新增一个叫conf的bean,用来读取db.properties中的配置信息, 而dataSource中的一些field改为从conf读取
 */
var ioc = {
		conf : {
			type : "org.nutz.ioc.impl.PropertiesProxy",
			fields : {
				paths : ["custom/db.properties", "custom/mail.properties"]
			}
		},
		dataSource : {
			type : "com.alibaba.druid.pool.DruidDataSource",
			events : {
				create : "init",
				depose : "close"
			},
			fields : {
				url : {java : "$conf.get('db.url')"},
				username : {java : "$conf.get('db.username')"},
				password : {java : "$conf.get('db.password')"},
				maxActive : {java : "$conf.get('db.maxActive')"},
				validationQuery : {java : "$conf.get('db.validationQuery')"},
				testWhileIdle : true,
				/* 加入对DruidDataSource的监控选项 */
				filters : "mergeStat", //filters是druid定义的一些过滤器,mergeStat是带合并的sql状态过滤器
				connectionProperties : "druid.stat.slowSqlMillis=2000" //2000代表如果sql执行超过2秒,就输出日志
			}
		},
		dao : {
			type : "org.nutz.dao.impl.NutDao",
			args : [{refer : "dataSource"}]
		}
};